home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Wipes ƒ / BoxOut wipe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-08  |  2.2 KB  |  66 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        BoxOut wipe.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define        BOXES    50    /* increase this for a finer grained but more timely effect */
  32. #define CorrectTime 2
  33. #define theWindowWidth (boundsRect.right-boundsRect.left)
  34. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  35.  
  36. pascal short BoxOutWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  37.  
  38. pascal short BoxOutWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  39. {
  40.     Rect    theRect;
  41.     int        cenx, ceny;
  42.     int        boxnum;
  43.     
  44.     cenx = theWindowWidth / 2;
  45.     ceny = theWindowHeight / 2;
  46.     
  47.     for(boxnum = 0; boxnum <= BOXES; boxnum++)
  48.     {
  49.         StartTiming();
  50.         
  51.         /* this is not the most efficient method, but the overhead of the
  52.         multiplies and the redundant copying is hidden by the timing mechanism */
  53.         theRect.left = cenx - ((boxnum * cenx) / BOXES);
  54.         theRect.right = cenx + ((boxnum * cenx) / BOXES);
  55.         theRect.top = ceny - ((boxnum * ceny) / BOXES);
  56.         theRect.bottom = ceny + ((boxnum * ceny) / BOXES);
  57.         OffsetRect(&theRect, boundsRect.left, boundsRect.top);
  58.         
  59.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  60.                 &theRect, &theRect, 0, 0L);
  61.         TimeCorrection(CorrectTime);
  62.     }
  63.     
  64.     return 0;
  65. }
  66.